package com.sj.uabrowser.net;


import com.sj.uabrowser.app.Constant;
import com.sj.uabrowser.mvp.main.bean.HomeTab;
import com.sj.uabrowser.mvp.main.bean.MainNewFuncs;
import com.sj.uabrowser.mvp.main.bean.News;
import com.sj.uabrowser.mvp.main.bean.PageBean;
import com.sj.uabrowser.mvp.video.bean.NVideoItem;
import com.sj.uabrowser.mvp.video.bean.NVideoTab;
import com.sj.uabrowser.mvp.video.bean.VideoNav;
import com.sj.uabrowser.mvp.wea.bean.LocationCity;
import com.sj.uabrowser.mvp.wea.bean.SearchCity;
import com.sj.uabrowser.net.bean.AboutMe;
import com.sj.uabrowser.net.bean.Banners;
import com.sj.uabrowser.net.bean.FeedBacks;
import com.sj.uabrowser.net.bean.KeyContent;
import com.sj.uabrowser.net.bean.MainFunc;
import com.sj.uabrowser.net.bean.NavUrlSearch;
import com.sj.uabrowser.net.bean.NewUrl;
import com.sj.uabrowser.net.bean.NewsTabItem;
import com.sj.uabrowser.net.bean.PushInfo;
import com.sj.uabrowser.net.bean.VideoTab;
import com.sj.uabrowser.net.bean.Weathers;

import java.util.HashMap;
import java.util.List;
import java.util.TreeMap;

import io.reactivex.Observable;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.QueryMap;
import retrofit2.http.Url;

public interface ServiceApi {

    @GET("v_api/v1/nav?pid="+Constant.PID)
    Observable<MainNewFuncs> GetMainFuncs();

    @POST(Constant.CATLIST)
    @FormUrlEncoded
    Observable<PageBean<HomeTab>> GetNewsTab(
            @FieldMap TreeMap<String, Object> params
    );

    @POST(Constant.RUISHIDATA)
    @FormUrlEncoded
    Observable<PageBean<News>> GetNewsData(
            @FieldMap TreeMap<String, Object> params
    );


    @POST("nav-info/recommend-nav-list")
    @FormUrlEncoded
    Observable<MainNewFuncs> GetMainFuncs(
            @FieldMap TreeMap<String, Object> params
    );

    @POST("nav-info/search-nav-list")
    @FormUrlEncoded
    Observable<NavUrlSearch<KeyContent>> SearchNavList(
            @FieldMap TreeMap<String, Object> params
    );

//    @POST("interface-edition/version-info")
//    @FormUrlEncoded
//    Observable<VersionInfo> VersionInfo(
//            @FieldMap TreeMap<String, Object> params
//    );

    @POST("interface-edition/user-version-upgrade")
    @FormUrlEncoded
    Observable<Object> UserVersionUpgrade(@FieldMap TreeMap<String, Object> params);

    @POST("help-advice/save-advice")
    @FormUrlEncoded
    Observable<BaseResponseNewBean> SaveAdvice(
            @FieldMap TreeMap<String, Object> params
    );

    @POST("help-advice/get-advice")
    @FormUrlEncoded
    Observable<FeedBacks> GetAdvice(
            @FieldMap TreeMap<String, Object> params
    );

    @POST("configuration-info/about-info")
    @FormUrlEncoded
    Observable<AboutMe> AboutInfo(
            @FieldMap TreeMap<String, Object> params
    );

    @POST("user-mobile-info/save-info")
    @FormUrlEncoded
    Observable<MainFunc> SaveInfo(
            @FieldMap TreeMap<String, Object> params
    );

    @POST("user-mobile-info/get-info")
    @FormUrlEncoded
    Observable<MainFunc> GetInfo(
            @FieldMap TreeMap<String, Object> params
    );



    /**
     * Tab导航
     * @param params
     * @return
     */
    @POST("tab-nav/tab-list")
    @FormUrlEncoded
    Observable<com.sj.uabrowser.net.bean.PageBean<NewsTabItem>> GetTabList(
            @FieldMap TreeMap<String, Object> params
    );


    /**
     * 开机广告
     * @param params
     * @return
     */
    @POST("app-advert/start-list")
    @FormUrlEncoded
    Observable<Banners> GetBanners(
            @FieldMap TreeMap<String, Object> params
    );


    @POST("bury-port/save-bury")
    @FormUrlEncoded
    Observable<Object> saveBury(
            @FieldMap TreeMap<String, Object> params
    );




    @POST("api/video/categories")
//    @POST("video/tab-list")
    @FormUrlEncoded
    Observable<List<NVideoTab>> TabVideoList(
            @FieldMap TreeMap<String, Object> params
    );

    @POST("api/video")
    @FormUrlEncoded
    Observable<List<NVideoItem>> VideoList(
            @FieldMap TreeMap<String,Object> params
    );

    @POST("video/refresh")
    @FormUrlEncoded
    Observable<VideoNav> VideoRefresh(
            @FieldMap TreeMap<String,Object> params
    );

    @POST("video/recommend")
    @FormUrlEncoded
    Observable<VideoNav> RecommendList(
            @FieldMap TreeMap<String,Object> params
    );


    @POST("video/report")
    @FormUrlEncoded
    Observable<Object> VideoReport(
            @FieldMap TreeMap<String, Object> params
    );


    @GET("api/video/parse")
//    @FormUrlEncoded
    Observable<NewUrl> VideoApars(
            @QueryMap TreeMap<String, Object> params
    );

    @POST("city-weather/get-weather")
    @FormUrlEncoded
    Observable<Weathers> getWeather(
            @FieldMap TreeMap<String, Object> params
    );

    @POST("city-weather/get-province")
    @FormUrlEncoded
    Observable<List<String>> getProvince(
            @FieldMap TreeMap<String, Object> params
    );

    @POST("city-weather/get-leader")
    @FormUrlEncoded
    Observable<List<String>> getLeader(
            @FieldMap TreeMap<String, Object> params
    );

//    @POST("city-weather/get-city")
//    @FormUrlEncoded
//    Observable<List<City>> getCity(
//            @FieldMap TreeMap<String, Object> params
//    );

//    获取省信息：v1/city-weather/get-province
//    获取市信息：v1/city-weather/get-leader
//    参数：* $province  string    省市
//    获取区信息：v1/city-weather/get-city
//    参数：* $city  string    城市

//    *  必填  vId      int     视频ID
//    *  必填  sources  int     来源ID
//    *  必填  videoUrl string  播放地址
//    *
//            * @return
//            *   videoUrl string     解析后的视频地址

    @POST("push-history/plist")
    @FormUrlEncoded
    Observable<List<PushInfo>> getPushList(@FieldMap TreeMap<String, Object> params);



//    统计分析：
//    @url：bsa.gif?
//    @param
//*uc   sting  用户渠道
//*sn   sting  手机序列号
//*mn  sting  手机名称
//*mm  sting  手机型号
//*v   sting  客户端版本
//*ct   int  客户端类型（1安卓、2IOS、3Wap、4PC）
//            *r   sting  页面路径
//*vt  int  客户端访问类型（0离开、1安装、2启动、3点击）
//            *at  string 时间戳
    @GET("bsa.gif")
    Observable<Object> Bsa(
            @QueryMap TreeMap<String, Object> params
    );

    @GET
    Call<ResponseBody> downloadFile(@Url String url);

    @GET Call<ResponseBody> rcd(@Url String url);


    //天气模块
    //    ?key=普陀
    @GET("tianqi/city/search.html")
    Observable<List<SearchCity>> fetchSearchCity(
            @QueryMap HashMap<String, Object> params
    );

    @GET("tianqi/city/tablepos.html")
    Observable<LocationCity> fetchCityId(
            @QueryMap HashMap<String, Object> params
    );

    @GET("t/new_mobile_json/{id}.json")
    Observable<ResponseBody> fetchMainContent2(
            @Path("id")String id
    );
}
